import { setUserStore } from "@/stores/user";
import { storeToRefs } from "pinia";
const userStore = setUserStore();
const { userInfo } = storeToRefs(userStore);
export const myDirective = {
  // 在绑定元素的 attribute 前
  // 或事件监听器应用前调用
  created(el: any, binding: any, vnode: any, prevVnode: any) {
    // 下面会介绍各个参数的细节
  },
  // 在元素被插入到 DOM 前调用
  beforeMount(el: any, binding: any, vnode: any, prevVnode: any) {},
  // 在绑定元素的父组件
  // 及他自己的所有子节点都挂载完成后调用
  mounted(el: any, binding: any, vnode: any, prevVnode: any) {
    if (!userInfo.value.buttons.includes(binding.value)) {
      el.remove();
    }
  },
  // 绑定元素的父组件更新前调用
  beforeUpdate(el: any, binding: any, vnode: any, prevVnode: any) {},
  // 在绑定元素的父组件
  // 及他自己的所有子节点都更新后调用
  updated(el: any, binding: any, vnode: any, prevVnode: any) {},
  // 绑定元素的父组件卸载前调用
  beforeUnmount(el: any, binding: any, vnode: any, prevVnode: any) {},
  // 绑定元素的父组件卸载后调用
  unmounted(el: any, binding: any, vnode: any, prevVnode: any) {},
};
